public class ThreadDemo12 {
    public static void main(String[] args) {
        Object object = new Object();
        Thread thread = new Thread(() -> {
            System.out.println("wait 等待");
            synchronized (object) {
                try {
                    object.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("wait 结束");
        });

        thread.start();//启动线程

        //让主线程进行等待（保证thread线程先执行）
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("notify 开始");
        synchronized(object) {
            object.notify();
        }
        System.out.println("notify 结束");

    }
}
